//
//  YWAnchorHotListTableViewCell.m
//  聆听FM
//
//  Created by dllo on 16/6/12.
//  Copyright © 2016年 Dark. All rights reserved.
//

#import "YWAnchorHotListTableViewCell.h"

@implementation YWAnchorHotListTableViewCell

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
        self.numLabel = [[UILabel alloc] init];
        _numLabel.font = [UIFont systemFontOfSize:14];
        _numLabel.textAlignment = 2;
        [self.contentView addSubview:_numLabel];
        
        self.backView = [[UIView alloc] init];
        _backView.backgroundColor = [UIColor whiteColor];
        [self.contentView addSubview:_backView];
        
        self.photoImageView = [[UIImageView alloc] init];
        [self.backView addSubview:_photoImageView];
        
        self.nickNameLabel = [[UILabel alloc] init];
        _nickNameLabel.font = [UIFont systemFontOfSize:15];
        [self.contentView addSubview:_nickNameLabel];
        
        self.vImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_vImageView];
        
        self.personDescribeLabel = [[UILabel alloc] init];
        _personDescribeLabel.font = [UIFont systemFontOfSize:13];
        _personDescribeLabel.textColor = [UIColor colorWithWhite:0.585 alpha:1.000];
        [self.contentView addSubview:_personDescribeLabel];
        
        self.iconImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_iconImageView];
        
        self.followersCountsLabel = [[UILabel alloc] init];
        _followersCountsLabel.textColor = [UIColor colorWithWhite:0.585 alpha:1.000];
        _followersCountsLabel.font = [UIFont systemFontOfSize:13];
        [self.contentView addSubview:_followersCountsLabel];
        
        self.arrowImageView = [[UIImageView alloc] init];
        [self.contentView addSubview:_arrowImageView];
    }
    return self;
}

- (void)layoutSubviews
{
    [super layoutSubviews];
    _numLabel.frame = CGRectMake(0 * FITWIDTH, 32.5 * FITHEIGHT, 30 * FITWIDTH, 15 * FITHEIGHT);
    _backView.frame = CGRectMake(40 * FITWIDTH, 10 * FITHEIGHT, 60 * FITWIDTH, 60 * FITHEIGHT);
    _photoImageView.frame = CGRectMake(1, 1, 60 * FITWIDTH - 2, 60 * FITHEIGHT - 2);
    _nickNameLabel.frame = CGRectMake(_backView.frame.origin.x + _backView.bounds.size.width + 10 * FITWIDTH, _backView.frame.origin.y - 5 * FITHEIGHT, 200 * FITWIDTH, 30 * FITHEIGHT);
    [_nickNameLabel sizeToFit];
    _vImageView.frame = CGRectMake(_nickNameLabel.frame.origin.x + _nickNameLabel.bounds.size.width + 5 * FITWIDTH, _nickNameLabel.frame.origin.y, 18 * FITHEIGHT, 18 * FITHEIGHT);
    _personDescribeLabel.frame = CGRectMake(_nickNameLabel.frame.origin.x, 30 * FITHEIGHT, 200 * FITWIDTH, 20 * FITHEIGHT);
    _iconImageView.frame = CGRectMake(_personDescribeLabel.frame.origin.x, _personDescribeLabel.frame.origin.y + 30 * FITHEIGHT, 18 * FITWIDTH, 12 * FITWIDTH);
    _followersCountsLabel.frame = CGRectMake(_iconImageView.frame.origin.x + 20 * FITWIDTH, _iconImageView.frame.origin.y - 4 * FITHEIGHT, 150 * FITWIDTH, 20 * FITHEIGHT);
    _arrowImageView.frame = CGRectMake(SCREENWIDTH - 30, 30 * FITHEIGHT, 20 * FITWIDTH, 20 * FITHEIGHT);
}

- (void)setAnchorHotListModel:(YWAnchorHotListModel *)anchorHotListModel
{
    if (_anchorHotListModel != anchorHotListModel) {

        _anchorHotListModel = anchorHotListModel;

        [_photoImageView sd_setImageWithURL:[NSURL URLWithString:anchorHotListModel.largeLogo] placeholderImage:[UIImage sd_animatedGIFNamed:@"占位图"]];
        _nickNameLabel.text = anchorHotListModel.nickname;
        _vImageView.image = [UIImage imageNamed:@"V"];
        _personDescribeLabel.text = anchorHotListModel.personDescribe;
        _iconImageView.image = [UIImage imageNamed:@"双人像"];
        float count = anchorHotListModel.followersCounts;
        if (count > 10000) {
            _followersCountsLabel.text = [NSString stringWithFormat:@"%.1f万", count / 10000];
        }
        else
        {
            _followersCountsLabel.text = [NSString stringWithFormat:@"%.f", count];
        }
        _arrowImageView.image = [UIImage imageNamed:@"向右"];
    }
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
